clear all
set more off
set scheme s2color
cd ""

use "sample.dta", clear

bysort city_ch: keep if _n == 1
gen csm_time = 1 + mdy(csm_month,csm_day,2020) - mdy(1,1,2020)

****************
* Subfigure (1)
****************

#delimit ;
twoway (kdensity csm_time if faction == 1, color(green)) (kdensity csm_time if faction == 0, color(orange)),
        xlabel(, labsize(small) tlength(0.8)) ylabel(, labsize(small) tlength(0.8) grid glwidth(vthin) nogextend)
        ytitle("Kernel density") xtitle("CSM timing (#th day of 2020)") 
        legend(label(1 "With informal tie") label(2 "Without informal tie") position(10) ring(0) col(1) size(small))
        graphregion(fcolor(white) color(white) icolor(white) margin(small)) plotregion(margin(vsmall));
#delimit cr

****************
* Subfigure (2)
****************

#delimit ;
twoway (kdensity betdays if faction == 1, color(green)) (kdensity betdays if faction == 0, color(orange)),
        xlabel(, labsize(small) tlength(0.8)) ylabel(, labsize(small) tlength(0.8) grid glwidth(vthin) nogextend)
        ytitle("Kernel density") xtitle("CSM timing (days since the first local case)") 
        legend(label(1 "With informal tie") label(2 "Without informal tie") position(10) ring(0) col(1) size(small))
        graphregion(fcolor(white) color(white) icolor(white) margin(small)) plotregion(margin(vsmall));
#delimit cr
